package com.amoyt.project.controller.admin;


import com.amoyt.project.domain.dto.query.PersonPageQuery;
import com.amoyt.project.domain.res.Result;
import com.amoyt.project.exception.BusinessException;
import com.amoyt.project.exception.enums.BusinessExceptionEnum;
import com.amoyt.project.service.admin.PovertyPersonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 贫困个人信息表（记录致贫核心人员） 前端控制器
 * </p>
 *
 * @author AmoyT
 * @since 2025-08-21
 */
@RestController
@RequestMapping("/admin/poverty-person")
@Tag(name = "贫困个人信息接口",description = "贫困个人信息表（记录致贫核心人员）接口")
public class PersonController {

    @Autowired
    private PovertyPersonService personService;

    /**
     * 列表
     */
    @Operation(summary = "致贫人员信息列表",method = "POST")
    @PostMapping("/list")
    @Parameter(name = "token",description = "访问令牌",required = true,in = ParameterIn.HEADER)
    @PreAuthorize("hasAnyRole('super_admin','prov_admin','city_admin','region_admin')")
    public Result list(@RequestBody PersonPageQuery query) {
        if (query == null || query.getPage() == null || query.getPageSize() == null){
            throw new BusinessException(BusinessExceptionEnum.PARAM_ERROR);
        }
        return personService.list(query);
    }
}

